package com.ys.peony.base.contract;

import android.os.Bundle;
import android.view.WindowManager;

import com.ys.peony.base.BaseActivity;
import com.ys.peony.base.BaseContract;
import com.ys.peony.base.BasePresenter;

/**
 * Created by 59153 on 2017/7/27.
 *
 * 描述：针对重构架构适用mvp模式，重新封装基础Activity
 */

public abstract class BasicActivity<V extends BaseContract.IBaseView, P extends BasePresenter> extends BaseActivity implements BaseContract.IBaseView{

    public P presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        presenter = initPresenter();
        if(presenter != null) {
            presenter.relateView(this);
        }
        super.onCreate(savedInstanceState);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    }


    protected abstract P initPresenter();

    @Override
    protected int getContentResId() {
        return 0;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        presenter.detachWindow();
        releaseResource();

    }
    public void releaseResource() {

    }
}
